package com.itxx.allTools.homeWork;

import java.util.Scanner;

public class Homework02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学员的姓名:");
        String name = sc.nextLine();
        System.out.println("请输入学员的年龄:");
        String age = sc.nextLine();
        System.out.println("请输入学员的身高:");
        String height = sc.nextLine();
        System.out.println("请输入学员的婚否:");
        String marry = sc.nextLine();
        System.out.println("请输入学员的性别:");
        String gender = sc.nextLine();

        //String -> Char

        Student2 student = new Student2(name, Integer.valueOf(age), Double.parseDouble(height), Boolean.parseBoolean(marry), gender.charAt(0));
        System.out.println(student);

    }
}

class Student2 {
    private String name;
    private int age;
    private double height;
    private boolean marry;
    private char gender;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Student2 student2 = (Student2) o;

        if (age != student2.age) return false;
        if (Double.compare(student2.height, height) != 0) return false;
        if (marry != student2.marry) return false;
        if (gender != student2.gender) return false;
        return name != null ? name.equals(student2.name) : student2.name == null;
    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        result = name != null ? name.hashCode() : 0;
        result = 31 * result + age;
        temp = Double.doubleToLongBits(height);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        result = 31 * result + (marry ? 1 : 0);
        result = 31 * result + (int) gender;
        return result;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Student2{");
        sb.append("name='").append(name).append('\'');
        sb.append(", age=").append(age);
        sb.append(", height=").append(height);
        sb.append(", marry=").append(marry);
        sb.append(", gender=").append(gender);
        sb.append('}');
        return sb.toString();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public boolean isMarry() {
        return marry;
    }

    public void setMarry(boolean marry) {
        this.marry = marry;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public Student2() {
    }

    public Student2(String name, int age, double height, boolean marry, char gender) {
        this.name = name;
        this.age = age;
        this.height = height;
        this.marry = marry;
        this.gender = gender;
    }
}